//
//  NewsCell.swift
//  Swift30Days
//
//  Created by licheng ke on 2017/3/9.
//  Copyright © 2017年 licheng ke. All rights reserved.
//

import UIKit

struct PersonData {
    let postImage : String
    let postTitle : String
    let authorImage: String
    let authorName: String
    
    init(pImage:String , pTitle:String ,
         authorImage:String , authorName:String) {
        postImage = pImage
        postTitle = pTitle
        self.authorImage = authorImage
        self.authorName = authorName
    }
    
    static func fakeDatas() -> [PersonData]{
        var datas : [PersonData] = [];
        datas.append(PersonData(pImage: "1", pTitle: "Love mountain.", authorImage: "a", authorName:"Allen Wang" ))
        datas.append(PersonData(pImage: "2", pTitle: "New graphic design - LIVE FREE", authorImage: "b", authorName:"Cole" ))
        datas.append(PersonData(pImage: "3", pTitle: "Summer sand", authorImage: "c", authorName:"Daniel Hooper" ))
        datas.append(PersonData(pImage: "4", pTitle: "Seeking for signal", authorImage: "d", authorName:"Noby-Wan Kenobi" ))
        return datas;
    }
    
}

class NewsCell: UITableViewCell {

    @IBOutlet weak var bgImageView: UIImageView!
    
    @IBOutlet weak var userImageView: UIImageView!
    
    @IBOutlet weak var likeLabel: UILabel!
    @IBOutlet weak var NameLabel: UILabel!
    
    var data : PersonData?
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

    }
    
    override func layoutSubviews() {
        super.layoutSubviews();
        if let data = data {
            bgImageView.image = UIImage(named:data.postImage)
            userImageView.image = UIImage(named:data.authorImage)
            likeLabel.text = data.postTitle
            NameLabel.text = data.authorName
        }
    }
    
    
    
}
